const app = getApp(),
  AJAX = app.$ajax,
  $wx = app.$wx;

Page({
  data: {
    page: 1
  },
  onLoad(options){
    this.setData({
      detailId: options.detail_id
    }, callback => {
      this.getAuthorDetail({
        limit: 20
      });

      this.authorProduction();
    });
   
  },

  getAuthorDetail(params = {}){
    let td = this.data;
    AJAX.getAuthorDetail({
      loadType: 'bar',
      id: td.detailId,
      page: td.page,
      ...params
    }).then(([status, res, msg]) => {
      console.log(res);
      if(status){
        this.setData({
          authorInfo: res
        });
      }else{
        $wx.showToast(msg);
      }
    });
  },

  authorProduction(){
    let td = this.data;
    AJAX.authorProduction({
      id: td.detailId,
      page: td.productionPage,
      limit: 20
    }).then(([status, res, msg]) => {
      console.log(res);
      if(status){
        this.setData({
          production: res
        });
      }
    });
  }
});